import java.io.*;
import java.util.Vector;
import java.net.*;


public class GameList {		
	
	public void addGame(String ipAdd,String name) {
		String msg = "hallo";
		Vector games = readGames();
		games.add(new Game(ipAdd,name));
		URL url = null;
		try {url = new java.net.URL("http://bogg.bo.funpic.de/kickoff/games.txt");}catch(Exception e){}
		HttpURLConnection conn = null;
		try {
			conn = (HttpURLConnection)url.openConnection();
		}catch(Exception e){ System.err.println("1:" + e);}
		try{	
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.connect();
			OutputStream os = conn.getOutputStream();
			os.write(msg.getBytes());
			System.out.println(conn.getPermission().getActions());
			conn.getOutputStream().flush();
			conn.getOutputStream().close();
		}catch(Exception e){ System.err.println("2:" + e);}
		/*
		try{
			ObjectOutputStream dis = new ObjectOutputStream(conn.getOutputStream());
			dis.writeObject(games);
			dis.flush();
			dis.close();
		}catch(Exception e){System.out.println(e);}
		*/
	}
	
	public Vector readGames(){
		Vector games = new Vector();
		URL url = null;
		try {url = new java.net.URL("http://bogg.bo.funpic.de/kickoff/games.txt");}catch(Exception e){}
		
		try{
			ObjectInputStream dis = new ObjectInputStream(url.openStream());
			games = (Vector)dis.readObject();	
			dis.close();
		}catch(Exception e){System.out.println("Read: " + e);}
		
		return games;
	}
	
	
}

class Game implements Serializable{
	public String ipAdd;
	public String name;
	static final long serialVersionUID =1231;
	
	public Game(String ia, String n){
		ipAdd = ia;
		name = n;
	}
}